package chapter2.No2_1_synchronized同步方法.a方法内的变量为线程安全;

/**
 * !
 *
 * @author liujian
 * @version 2016/11/11 0011
 */
public class TestObject {
    int i = 10;

    public void doTest(String userName) throws InterruptedException {

        if("a".equals(userName)) {
            i = 20;
            Thread.currentThread().sleep(1000);
        }else{
            i= 600;
        }

        System.out.println("当前线程执行线程为"+Thread.currentThread().getName()+"，i="+i);
    }
}
